package base

import (
	"enjoy_xxz/constant"
	"github.com/gin-gonic/gin"
	"net/http"
)

// 判断返回结果 错误信息
func RespData(c *gin.Context, data interface{}, err error) {
	if err == nil {
		c.JSON(http.StatusOK, gin.H{"code": constant.OKServer, "message": "成功", "data": data})
		return
	}
	c.JSON(http.StatusOK, gin.H{"code": constant.ErrServer, "message": err.Error(), "data": nil})
	return
}
